using System;
using System.Data;

using Wicresoft.Common;

namespace Wicresoft.Messages.Entity
{
    [Table("ErrorInfo", "", "Wicresoft.Messages.ConnectionString")]
    public class ErrorInfo : Info
    {
        #region SQL column name consts
        public const string SQLCOL_INFOID = "InfoID";
        public const string SQLCOL_INFOTYPE = "InfoType";
        public const string SQLCOL_CREATETIME = "CreateTime";
        public const string SQLCOL_ERRORMESSAGE = "ErrorMessage";
        public const string SQLCOL_STACKTRACE = "StackTrace";
        #endregion


        #region Contructors
        /// <summary>
        /// Construct empty entity
        /// </summary>
        public ErrorInfo() { }

        /// <summary>
        /// Construct entity by primary key, other fields will be assigned by 
        /// "Load" method.
        /// </summary>
        public ErrorInfo(Guid InfoID)
        {
            this.InfoID = InfoID;
        }
        #endregion

        public override void Init(DataRow row)
        {
            InfoID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_INFOID]);
            InfoType = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_INFOTYPE]);
            CreateTime = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_CREATETIME]);
            ErrorMessage = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_ERRORMESSAGE]);
            StackTrace = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_STACKTRACE]);
        }

        #region Properties
        #region Property <Guid> InfoID
        [Property("InfoID", 16, SqlDbType.UniqueIdentifier, false, true)]
        public Guid InfoID
        {
            get { return _InfoID; }
            set { _InfoID = value; }
        }
        private Guid _InfoID = Guid.Empty;
        #endregion

        #region Property <int> InfoType
        [Property("InfoType", 4, SqlDbType.Int, false, false)]
        public int InfoType
        {
            get { return _InfoType; }
            set { _InfoType = value; }
        }
        private int _InfoType = int.MinValue;
        #endregion

        #region Property <DateTime> CreateTime
        [Property("CreateTime", 16, SqlDbType.DateTime, false, false)]
        public DateTime CreateTime
        {
            get { return _CreateTime; }
            set { _CreateTime = value; }
        }
        private DateTime _CreateTime = DateTime.MinValue;
        #endregion

        #region Property <string> ErrorMessage
        [Property("ErrorMessage", 2147483646, SqlDbType.NText, false, false)]
        public string ErrorMessage
        {
            get { return _ErrorMessage; }
            set { _ErrorMessage = value; }
        }
        private string _ErrorMessage = null;
        #endregion

        #region Property <string> StackTrace
        [Property("StackTrace", 2147483646, SqlDbType.NText, false, false)]
        public string StackTrace
        {
            get { return _StackTrace; }
            set { _StackTrace = value; }
        }
        private string _StackTrace = null;
        #endregion
        #endregion




    }
}
